(require '[fx-clj.internal.util])
(fx-clj.internal.util/ns-start-loading 'fx-clj.core)


(ns fx-clj.core
  (:refer-clojure :exclude [run!])
  (:require
    [potemkin :refer [import-vars]]
    [fx-clj.core.run]
    [fx-clj.core.pset]
    [fx-clj.hiccup]
    [fx-clj.enlive]
    [fx-clj.elements]
    [fx-clj.css]
    [fx-clj.core.i18n]
    [fx-clj.util]
    [fx-clj.sandbox]
    [fx-clj.core.transforms]
    [fx-clj.core.extensibility]
    [fx-clj.core.binding]
    [fx-clj.impl.animation]
    [clojure.string :as str]))

;; <<----------------------
(fx-clj.internal.util/ns-libs-loaded 'fx-clj.core)
;; ---------------------->>
(declare ^:dynamic *resource-bundle*)

; declare styleable-classes
(declare accordion ambient-light anchor-pane arc area-chart axis bar-chart border-pane
  box bubble-chart button camera canvas category-axis cell chart check-box check-box-list-cell
  check-box-table-cell check-box-tree-cell check-box-tree-table-cell check-menu-item
  choice-box choice-box-list-cell choice-box-table-cell choice-box-tree-cell choice-box-tree-table-cell
  circle color-picker combo-box combo-box-base combo-box-list-cell combo-box-table-cell
  combo-box-tree-cell combo-box-tree-table-cell context-menu control cubic-curve custom-menu-item
  cylinder date-cell date-picker ellipse flow-pane grid-pane group h-box html-editor
  hyperlink image-view indexed-cell label labeled light-base line line-chart list-cell
  list-view media-view menu menu-bar menu-button menu-item mesh-view node number-axis
  pane parallel-camera parent password-field path perspective-camera pie-chart point-light
  polygon polyline popup-control progress-bar progress-bar-table-cell progress-bar-tree-table-cell
  progress-indicator quad-curve radio-button radio-menu-item rectangle region scatter-chart
  scroll-bar scroll-pane separator separator-menu-item shape shape-3-d slider sphere
  split-menu-button split-pane stacked-area-chart stacked-bar-chart stack-pane sub-scene
  svg-path swing-node tab table-cell table-column table-column-base table-row table-view
  tab-pane text text-area text-field text-field-list-cell text-field-table-cell text-field-tree-cell
  text-field-tree-table-cell text-flow text-input-control tile-pane titled-pane toggle-button
  tool-bar tooltip tree-cell tree-table-cell tree-table-column tree-table-row tree-table-view
  tree-view value-axis v-box web-view xy-chart )

; declare window-classes
(declare popup-window stage popup )

; declare other-classes
(declare tree-item file-chooser directory-chooser toggle-group row-constraints column-constraints )

; declare animation-classes
(declare fade-transition fill-transition parallel-transition path-transition pause-transition
  rotate-transition scale-transition sequential-transition stroke-transition translate-transition
  timeline )

(import-vars
  [fx-clj.core.run run! run<! run<!!]
  [fx-clj.core.pset pset!]
  [fx-clj.hiccup compile-fx build]
  [fx-clj.enlive at!]
  [fx-clj.sandbox sandbox]
  [fx-clj.css set-global-css!]
  [fx-clj.core.i18n with-locale with-resource-bundle
   get-resource-bundle get-locale get-resource]
  [fx-clj.util event-handler callback lookup]
  [fx-clj.core.binding property-ref observable-property bind<- bind<-> bind->])

(defn import-all [ns-sym]
  (eval
    `(potemkin/import-vars
       [~ns-sym
        ~@(keys (ns-publics (find-ns ns-sym)))])))

(import-all 'fx-clj.elements)
(import-all 'fx-clj.core.transforms)
(import-all 'fx-clj.impl.animation)

(comment
  (defn available-transforms
    "Prints information on available transform functions for use
    primarily in the [[at!]] function."
    {:doc/format :markdown}
    []
    (doseq [xform @fx-clj.core.extensibility/defined-transforms]
      (let [{:keys [doc]} (meta xform)]
        (println xform)
        (println doc)
        (println))))

  (alter-meta!
    #'fx-clj.core/at!
    update-in [:doc]
    (fn [doc]
      (str doc
           (str/join
             "\n"
             (for [xform @fx-clj.core.extensibility/defined-transforms]
               (let [{:keys [ns name]} (meta xform)]
                 (str "  [[" name "]]"))))))))


(fx-clj.internal.util/ns-loaded 'fx-clj.core)